
#if !defined (_MLVECX_H)
#define _MLVECX_H

#include "mlMath.h"

namespace ml
{

	template <class X, uint D> class VecX
	{
	public:
		
		VecX(void) 
		{ 
		}
		VecX(const VecX<X,D> &a) 
		{
			for (uint i = 0; i < D; ++i) Element[i] = a.Element[i];
		}
		~VecX(void) 
		{
		}

		VecX<X,D> &operator =(const VecX<X,D> &a)
		{
			for (uint i = 0; i < D; ++i) Element[i] = a.Element[i];
			return *this;
		}
		bool operator ==(const VecX<X,D> &a) const
		{
			for (uint i = 0; i < D; ++i) 
			{
				if (Element[i] != a.Element[i]) return 0;
			}
			return 1;
		}
		bool operator !=(const VecX<X,D> &) const
		{
			for (uint i = 0; i < D; ++i) 
			{
				if (Element[i] == a.Element[i]) return 0;
			}
			return 1;
		}
		VecX<X,D> operator -(void) const
		{
			VecX<X,D> v(*this);
			for (uint i = 0; i < D; ++i) v.Element[i] = -v.Element[i];
			return v;
		}
		VecX<X,D> operator +(const VecX<X,D> &a) const
		{
			VecX<X,D> v(*this);
			for (uint i = 0; i < D; ++i) v.Element[i] = v.Element[i] + a.Element[i];
			return v;
		}
		VecX<X,D> operator -(const VecX<X,D> &a) const
		{
			VecX<X,D> v(*this);
			for (uint i = 0; i < D; ++i) v.Element[i] = v.Element[i] - a.Element[i];
			return v;
		}
		VecX<X,D> operator *(X a) const
		{
			VecX<X,D> v(*this);
			for (uint i = 0; i < D; ++i) v.Element[i] = v.Element[i] * a;
			return v;
		}
		VecX<X,D> operator /(X a) const
		{
			VecX<X,D> v(*this);
			for (uint i = 0; i < D; ++i) v.Element[i] = v.Element[i] / a;
			return v;
		}
		VecX<X,D> &operator +=(const VecX<X,D> &a)
		{
			for (uint i = 0; i < D; ++i) Element[i] = Element[i] + a.Element[i];
			return *this;
		}
		VecX<X,D> &operator -=(const VecX<X,D> &a)
		{
			for (uint i = 0; i < D; ++i) Element[i] = Element[i] - a.Element[i];
			return *this;
		}
		VecX<X,D> &operator *=(X a)
		{
			for (uint i = 0; i < D; ++i) Element[i] = Element[i] * a;
			return *this;
		}
		VecX<X,D> &operator /=(X a)
		{
			for (uint i = 0; i < D; ++i) Element[i] = Element[i] / a;
			return *this;
		}
		X &operator [](uint i)
		{
			if (i >= D) return Element[0];
			return Element[i];
		}

		X * toPtr(void)
		{	
			return (X *)this;
		}

		void normalize(void);
		void zero(void);

	protected:

		X Element[D];

	};

	//VecX<X,D> operator *(float, const VecX<X,D> &);

}

#endif